# -*- coding: utf-8 -*-
from kivy.app import App
from kivy.lang import Builder
from kivy.metrics import dp
from kivy.properties import ObjectProperty, NumericProperty, StringProperty
from kivy.uix.image import Image
from kivy.uix.screenmanager import Screen
from kivy.core.window import Window
from kivy.uix.behaviors import ButtonBehavior

from kivymd.bottomsheet import MDListBottomSheet, MDGridBottomSheet
from kivymd.button import MDIconButton
from kivymd.date_picker import MDDatePicker
from kivymd.dialog import MDDialog
from kivymd.label import MDLabel
from kivymd.list import ILeftBody, ILeftBodyTouch, IRightBodyTouch, BaseListItem
from kivymd.material_resources import DEVICE_TYPE
from kivymd.navigationdrawer import MDNavigationDrawer, NavigationDrawerHeaderBase
from kivymd.selectioncontrols import MDCheckbox
from kivymd.snackbar import Snackbar
from kivymd.theming import ThemeManager
from kivymd.time_picker import MDTimePicker
from kivymd.menu import MDDropdownMenu

write_confe_kv = '''
#:import Toolbar kivymd.toolbar.Toolbar
#:import ThemeManager kivymd.theming.ThemeManager
#:import MDNavigationDrawer kivymd.navigationdrawer.MDNavigationDrawer
#:import NavigationLayout kivymd.navigationdrawer.NavigationLayout
#:import NavigationDrawerDivider kivymd.navigationdrawer.NavigationDrawerDivider
#:import NavigationDrawerToolbar kivymd.navigationdrawer.NavigationDrawerToolbar
#:import NavigationDrawerSubheader kivymd.navigationdrawer.NavigationDrawerSubheader
#:import MDCheckbox kivymd.selectioncontrols.MDCheckbox
#:import MDSwitch kivymd.selectioncontrols.MDSwitch
#:import MDList kivymd.list.MDList
#:import OneLineListItem kivymd.list.OneLineListItem
#:import TwoLineListItem kivymd.list.TwoLineListItem
#:import ThreeLineListItem kivymd.list.ThreeLineListItem
#:import OneLineAvatarListItem kivymd.list.OneLineAvatarListItem
#:import OneLineIconListItem kivymd.list.OneLineIconListItem
#:import OneLineAvatarIconListItem kivymd.list.OneLineAvatarIconListItem
#:import MDTextField kivymd.textfields.MDTextField
#:import MDSpinner kivymd.spinner.MDSpinner
#:import MDCard kivymd.card.MDCard
#:import MDSeparator kivymd.card.MDSeparator
#:import MDDropdownMenu kivymd.menu.MDDropdownMenu
#:import get_color_from_hex kivy.utils.get_color_from_hex
#:import colors kivymd.color_definitions.colors
#:import SmartTile kivymd.grid.SmartTile
#:import MDSlider kivymd.slider.MDSlider
#:import MDTabbedPanel kivymd.tabs.MDTabbedPanel
#:import MDTab kivymd.tabs.MDTab
#:import MDProgressBar kivymd.progressbar.MDProgressBar
#:import MDThemePicker kivymd.theme_picker.MDThemePicker
#:import MDBottomNavigation kivymd.tabs.MDBottomNavigation
#:import MDBottomNavigationItem kivymd.tabs.MDBottomNavigationItem

<WriteConfeScreen>:
    id: writeconfescreen
    name: 'WriteConfeScreen'
    padding: dp(10)
    BoxLayout:
        orientation: 'vertical'
        Toolbar:
            title: "发布表白"
            pos_hint: {'center_x': 0.5, 'center_y': 0.25}
            md_bg_color: app.theme_cls.primary_color
            left_action_items: [['arrow-left', lambda x: app.load_screen('MainScreen', direction='right')]]
            right_action_items: [['check', lambda x: None]]
        ScrollView:
            BoxLayout:
                orientation: 'vertical'
                size_hint_y: None
                height: self.minimum_height
                padding: dp(24)
                spacing: 36
                MDTextField:
                    multiline: True
                    hint_text: "写下你的表白吧~"
                    helper_text: "内容需大于5个字符~"
                    helper_text_mode: "persistent"
                
                BoxLayout:
                    orientation: 'vertical'
                    spacing: 20
                    size_hint: 1, None
                    height: self.minimum_height
                    MDLabel:
                        height: 24
                        halign: 'left'
                        text: ' 添加图片'
                        x: root.x + 32
                        font_style: 'Body1'
                        theme_text_color: 'Primary'
                    ImageButton:
                        id: img
                        mipmap: True
                        source: 'pic/logo.png'
                        size_hint: None, None
                        size: 96, 96                          
                    # FileChooserListView:
                        
                BoxLayout:
                    spacing: 10
                    MDLabel:
                        font_style: 'Body1'
                        theme_text_color: 'Primary'
                        text: "匿名"
                        halign: 'left'
                    MDSwitch:
                        size_hint:    None, None
                        size:        dp(36), dp(48)
                        pos_hint:    {'center_x': 0.8, 'center_y': 0.5}
                        _active:        False
                MDSpinner:
                    id: new_confe_spinner
                    size_hint: None, None
                    size: dp(46), dp(46)
                    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                    active: True
'''


class WriteConfeScreen(Screen):

    Builder.load_string(write_confe_kv)


class ImageButton(ButtonBehavior, Image):
    def on_press(self):
        Snackbar(text="暂不支持添加图片~").show()
